package com.bigdata.bookinfo.controller;

import com.bigdata.bookinfo.dao.MainDao;
import com.bigdata.bookinfo.pojo.Book;
import com.bigdata.bookinfo.pojo.KeyAndScore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class ViewController {

    @Autowired
    MainDao mainDao;

    @GetMapping("/hello")
    public String hello(Model model){
        List<KeyAndScore> yearsNum = mainDao.selectYearsNum();
        List<KeyAndScore> authorNum = mainDao.selectAuthorNum();
        List<KeyAndScore> pressNum = mainDao.selectPressNum();
        List<KeyAndScore> commentNum = mainDao.selectCommentNum();
        List<KeyAndScore> commentDis = mainDao.selectCommentDis();
        List<KeyAndScore> keywordNum = mainDao.selectKeywordNum();
        List<KeyAndScore> priceDis = mainDao.selectPriceDis();
        model.addAttribute("yearsNum",yearsNum);
        model.addAttribute("authorNum",authorNum);
        model.addAttribute("pressNum",pressNum);
        model.addAttribute("commentNum",commentNum);
        model.addAttribute("commentDis",commentDis);
        model.addAttribute("keywordNum",keywordNum);
        model.addAttribute("priceDis",priceDis);
        return "hello";
    }
}
